﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Milan.Text
{
	public static class Parser
	{
		public static string[] ParseCSV(string line)
		{
			List<string> returns = new List<string>();
			Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);

			foreach (Match match in csvSplit.Matches(line))
				returns.Add(match.Value.TrimStart(',').Trim('\"').Trim());
			return returns.ToArray();
		}
	}
}
